<?php

/*------------------------------------------------
*
*   Explay Engine Content Management System.
*   Copyright © 2008 Golovdinov Alexander.
*
*-------------------------------------------------
*
*   Oficial site: wwww.alex-home.spb.ru/explay.html
*   Contact e-mail: golovdinov@gmail.com
*
*   GNU General Public License original source:
*   http://www.gnu.org/licenses/gpl-3.0.html
*
------------------------------------------------*/

if (!defined ('EXPLAY')) exit;

past_path (array (array ('', 'Лог авторизаций в панель администратора')));

print "\n<script>document.title='Лог авторизаций в панель администратора - ".$SITE['site_name']."';</script>";

if (isset($_POST['clear'])) {
	$file_admin = fopen ($_SERVER['DOCUMENT_ROOT'].'/explaylogs/admin_pan_log.txt', 'w');
	fclose ($file_admin);
	site_message ('Лог-файл входа в админпанель очищен');
}

$log_file = file ($_SERVER['DOCUMENT_ROOT'].'/explaylogs/admin_pan_log.txt');
$string = '';

foreach ($log_file as $post) {
	$post = explode ('<==>', $post);
	
	if (trim($post[3]) == 'false') {
		$color = 'style="color:red"';
		$r = 'Неуспешно';
	} else {
		$color = '';
		$r = 'Успешно';
	}
	$string .= "\r\n<tr $color><td class=\"ad_tr\">{$post[0]}</td>".
		"<td class=\"ad_tr\">{$post[1]}</td>".
		"<td class=\"ad_tr\">".date('d.m.Y H:i', $post[2])."</td>".
		"<td class=\"ad_tr\">$r</td></tr></tr>";
}

$table = "<p align=\"center\"><table width=\"50%\" align=\"center\" cellspacing=\"0\" cellpadding=\"2\">
<tr>
	<td class=\"top_header_name\">Логин</td>
	<td class=\"top_header_name\">IP</td>
	<td class=\"top_header_name\">Время</td>
	<td class=\"top_header_name\">Статус</td>
</tr>$string
</table></p>
<p><form method=\"post\" action=\"admin.php?do=logs\" style=\"text-align:center;\"><input type=\"submit\" name=\"clear\" value=\"Очистить\" /></form></p>
";
past_table ('Лог входа в админпанель', $table);
come_back ('панели администратора', 'admin.php');

